@extends('layouts.art')
@section('content')
<form class="form-horizontal" method="post" action="/blog">
{{csrf_field()}}
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">标题</label>
        <div class="col-sm-8">
            <input type="title" placeholder="{{$art->title}}" class="form-control" id="title" name="title">
        </div>
    </div>


    <div class="form-group">
        <label for="inputEmail3"  class="col-sm-2 control-label">内容</label>
        <div class="col-sm-8">
            <textarea class="form-control" rows="5"  id="content" name="content">{{$art->content}}</textarea>
        </div>
    </div>


    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default">编辑</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <button type="button" id="yulan" class="btn btn-default">预览</button>
        </div>
    </div>
</form>
<center>
<table border="1">
    <tr height="60">
        <td>标题: </td><td  width="700"><h1></h1></td>
    </tr>
    <tr height="60">
        <td>内容: </td><td><h2></h2></td>
    </tr>
</table>
</center>
    
    
    
<script>


    $('#yulan').click(function(){
        var title=$('#title').val();

        var content=$('#content').val();
        // alert(content);
        $.post('/yulan/{{$art->id}}',{'title':title,'content':content,'_token':'{{ csrf_token() }}'},function(data){
            // document.write(data);
            // alert(data);

           var data =(new Function("return "+data))();
            // alert(data.content);
            // var data=new Function("return" + data);

            // alert(data.content);
            // alert(data.content);
            $('h1').html(data.title);
            $('h2').html(data.content);
    });


    });
    

</script>
@endsection